package com._520it.crm.service.impl;

import com._520it.crm.domain.Premium;
import com._520it.crm.mapper.PremiumMapper;
import com._520it.crm.page.PageResult;
import com._520it.crm.query.QueryObject;
import com._520it.crm.service.IPremiumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * Created by 呆 on 2017/10/3.
 */
@Service
public class PremiumServiceImpl implements IPremiumService {
    @Autowired
    private PremiumMapper premiumMapper;
    @Override
    public int deleteByPrimaryKey(Long id) {
        return premiumMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Premium premium) {
        return premiumMapper.insert(premium);
    }

    @Override
    public Premium selectByPrimaryKey(Long id) {
        return premiumMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Premium> selectAll() {
        return premiumMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKey(Premium premium) {
        return premiumMapper.updateByPrimaryKey(premium);
    }

    @Override
    public PageResult query(QueryObject qo) {
        Integer totalCount = premiumMapper.queryforCount(qo);
        if (totalCount==0){
            return new PageResult(0, Collections.EMPTY_LIST);
        }
        List<Premium> data = premiumMapper.queryforList(qo);
        return new PageResult(totalCount,data);
    }
}
